<template>
  <div class="user-panel">
    <el-dropdown>
      <span class="el-dropdown-link">
        <el-avatar icon="UserFilled" />
        <span class="username">管理员</span>
      </span>
      <template #dropdown>
        <el-dropdown-menu>
          <el-dropdown-item>个人中心</el-dropdown-item>
          <el-dropdown-item @click="logout">退出登录</el-dropdown-item>
        </el-dropdown-menu>
      </template>
    </el-dropdown>
  </div>
</template>

<script setup>
import { useUserStore } from '@/stores/user'

const userStore = useUserStore()

const logout = () => {
  userStore.logout()
  window.location.reload()
}
</script>

<style scoped>
.user-panel {
  margin-right: 20px;
  .username {
    margin-left: 8px;
  }
}
</style> 